{% extends "bootstrap/base.html" %}
{% block title %}whenmgone{% endblock %}

{% block head %}
{{ super() }}
<!-- ico -->
<link rel="shortcut icon" href="{{ url_for('static',filename = 'ghost_ico.ico') }}" type="image/x-icon">
<!-- cdn css -->
<link href="//cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="http://simditor.tower.im/assets/styles/simditor.css" />
<!-- self css -->
<link rel="stylesheet" href="{{ url_for('static', filename = 'lastwill.css') }}">

{% endblock %}

{% block content %}
<!-- navbar -->
<!-- navbar -->
<nav class="navbar container">
  <div class="col-md-4">
    <a href="/login"><h1>whenmgone</h1></a>     
  </div>
  <div class="col-md-2 col-md-offset-6">
    <br>
  
    {% if current_user.is_authenticated() %}
    <h5 class="login">{{ current_user.email }}</h5>
    {% else %}
      stranger
    {% endif %}    
  </div>

</nav>

<!-- register -->
<div class="container main_bd">
  <div class="stepbystep col-md-12">
    <ul class="nav navbar-nav col-md-12">
      <li class="step col-md-3">
        <a href="/contact">联系人</a>
      </li>
      <li class="step col-md-3 active">
<!--         <div id="triangle-right-active"></div> -->
        <a href="/lastwill">遗嘱</a>
      </li>
      <li class="step col-md-3">
        <!-- <div id="triangle-right"></div> -->
        <a href="/heatbeat">心跳</a>
      </li>
      <li class="step col-md-3">
        <!-- <div id="triangle-right"></div> -->
        <a href="/preview">预览</a>
      </li>


    </ul>
  </div>


<!-- 遗嘱页 -->
  <div class="contacts-add col-md-8">
  <form action="/lastwill" method="POST">
    <h3>遗嘱</h3>
    <br>

    <div class="form-group">
      <!-- <label for="inputEmail3" class="col-sm-4 control-label">姓名</label> -->
      <!-- <div class="col-sm-8"> -->
        <!-- <textarea class="form-control note"></textarea> -->
        {% if decode_value %}
          {{ form.content01(class="form-control note",value=decode_value) }}
        {% else %}
          {{ form.content01(class="form-control note",value="") }}
        {% endif %}
      <!-- </div> -->
    </div>



    <div class="form-group">
      <div class="col-sm-8">
        <!-- <button type="submit" class="btn btn-default">保存</button> -->
        {{ form.submit(class="btn btn-default") }}
      </div>

      <div class="col-md-offset-2 col-sm-2">
        {% if message %} 
        <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
        {{ message }}
        {% endif %}
      </div>
    </div>
  </form>
  </div>

<div class="contacts-list col-md-4">
</div>

<div class="contacts-help col-md-4">
  <div class="tip">
    <h6>Tip:</h6>
    <p>请写下您最后的留言，当您离开这个世界的时候，我们将为您转达您的信息！</p>
    <p>当前为测试版本，加密级别较低，请勿留下重要信息，避免泄露风险！</p>
  </div>
</div>
</div>


<!-- footer -->
<footer class="footer">
    <div class="container">
    <hr>
        <p>Copyright © whenmgone 2015</p>
    </div>
</footer>

<script src="//cdn.bootcss.com/jquery/2.1.4/jquery.js"></script>
<script src="//cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.js"></script>



<script type="text/javascript" src="http://simditor.tower.im/assets/scripts/module.js"></script>
<script type="text/javascript" src="http://simditor.tower.im/assets/scripts/hotkeys.js"></script>
<script type="text/javascript" src="http://simditor.tower.im/assets/scripts/uploader.js"></script>
<script type="text/javascript" src="http://simditor.tower.im/assets/scripts/simditor.js"></script>


<script type="text/javascript">
  var editor = new Simditor({
    textarea: $('.note')
    // setValue 'hello world'
    //optional options
    // _this.editor.setValue('hello world');
  });
  editor.focus();
  // editor.setValue 'hello world';
  // var content = html_entity_decode(str({{ decode_value }}));
  // var content_value = {{ decode_value }}

  // editor.focus();
  // var content = $('.note').attr('value');
  $(document).ready(function(){
    $("form").submit( function () {
      $('.note').attr('value',editor.getValue())
      // editor.setValue(content);
    } );
    // editor.setValue 'hello world';
    if ($('textarea').text() != "") {
      $('.note').attr('value',$('textarea').text())
    };
    
    content = $('.note').attr("value");
    editor.setValue(content);
  });
  // $(window).unload( function () { 
  //   content = $('.note').attr("value");
  //   editor.setValue(content);
  // });




</script>





{% endblock %}